package com.dao;


import org.apache.ibatis.annotations.*;

import com.entity.Cart;

import java.util.List;

public interface CartMapper {

    @Select("select * from cart")
    List<Cart> selectALl();

    @Insert("insert into cart(good_num,good_name,shop_id,price,good_id,user_id,img)\n" +
            "        values (#{good_num}, #{good_name}, #{shop_id}, #{price}, #{good_id}, #{user_id}, #{img})")
    int addCart(Cart cart);

    @Delete("delete from cart where cart_id=#{cart_id}")
    public  int deleteCart(@Param("cart_id") int cart_id);

    @Update("update cart set good_num=#{good_num} where cart_id=#{cart_id}")
    public int update(@Param("cart_id") int cart_id,@Param("good_num") int good_num);
    
    @Select("select * from cart where user_id=#{userid}")
    List<Cart> selectCartByUserid(int userid);
    
    @Select("select user_id from cart where cart_id=#{cart_id}")
    int selectUserIdByCartId(int cart_id);
    
    @Select("select * from cart where cart_id=#{cart_id}")
    public Cart selectCartByCartId(Integer cart_id);

}
